<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>{{.title}}</title>
    <meta charset="utf-8" name="keywords" content="{{.system.keywords}}" />
    <meta charset="utf-8" name="description" content="{{.system.description}}" />
    <link rel ="shortcut Icon" href="{{.system.pathname}}">
    <link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/css/index.min.css?v=123" />
    <link rel="stylesheet" type="text/css" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/font/iconfont.css">
    <link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/css/xcConfirm.css">
    <link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/css/toast.css" />
    <link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/css/jedate.css" rel="stylesheet" />
    <style type="text/css">
      .searchCont .searchPrd dl .a-wrap a{width: calc(100% - 40px);
      text-overflow: -o-ellipsis-lastline;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;height: 40px;}
      .select div{float: left;width: auto;height: 40px;line-height: 40px}
      .select div input{height: 22px;width: 55px;outline: 0;margin:0 ; }
      .select div button{background: #e4393c;padding:5px 10px;line-height: 20px;border: 0;outline: none;color: #fff;border-radius: 3px;}
      input::-webkit-outer-spin-button,
      input::-webkit-inner-spin-button {
          -webkit-appearance: none;
      }
      input[type="number"]{
          -moz-appearance: textfield;
      }
      .searchHd .attr {
          width: 1230px;
          margin: 0 auto;
          overflow: auto;
          /*border: 1px solid #ddd;*/
          margin-bottom: 10px;
      }
    .searchHd .attr li {
      position: relative;
      margin: 4px 5px 0 0;
      padding: 0 19px 0 4px;
      float: left;
      max-width: 144px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      border: 1px solid #e8e8e8;
      height: 18px;
      line-height: 18px;
      color: #666;
      text-decoration: none;
      padding-right: 5px !important;
    }
    .searchHd .attr li:nth-of-type(1) {
      border: 0;
      height: 20px;line-height: 20px;
      
    }
    .searchHd .attr li:hover {
      border-color:#e4393c;
      cursor: pointer;
    }
    .searchHd .attr li:hover .close {
      color:#e4393c !important;
    }
    .searchHd .attr li i{
      font-size: 12px;
    }
     dl{
      position: relative;
    }
    dl .x{
      position: absolute;
      width: 50px;height: 50px;top: -5px;left: 0;z-index: 9
    }
    .a-wrap {
      display: block;
      height: 40px;
      overflow: hidden;
    }
    </style>
  </head>
  
  <body style="overflow-x: auto!important;" class="search">
    <!--from fragment-->
    {{template "pc/public/head.html" .}}
    {{template "pc/public/search.html" .}}
    <div class="searchHd">
      {{if .attrcolumn}}
      <ul class="attr">
        <li>筛选条件<i class='iconfont'>&#xe6f7;</i></li>
        {{range .attrcolumn}}
        {{if .isselect}}
        <li data-id="{{.id}}" class="delAttr">{{.name}}：{{range .attr}}{{if .isthis}}{{.name}}{{end}}{{end}} <i class="iconfont close">&#xe759;</i></li>
        {{end}}
        {{end}}
      </ul>
      {{end}}
      {{if .brand}}
      <div class="brand">
        <dl>
          <dt>品牌</dt>
          <dd>
            <ul>
              {{range .brand}}
              <li><a href="{{$.brandurl}}bid={{.id}}"><img src="{{.pathname}}" alt=""></a></li>
              {{end}}
            </ul>
          </dd>
        </dl>
      </div>
      {{end}}
      {{if .attrcolumn}}
      <div class="other">
        {{range $k,$v:=.attrcolumn}}
        <dl>
          <dt>{{$v.name}}</dt>
          {{if $v.isselect}}
          {{else}}
          <dd>&nbsp;{{range $v.attr}}<a href="{{$.attrurl}}a{{$v.id}}={{.id}}">{{.name}}</a>{{end}}</dd>
          {{end}}
        </dl>
        {{end}}
      </div>
      {{end}}
      <div class="select">
        <ul>
          <a {{if eq .status ""}}class="on"{{end}} href="{{.statusurl}}"><li>综合排序</li></a>
          <a {{if eq .status "1"}}class="on"{{end}} href="{{.statusurl}}status=1"><li>销量优先</li></a>
          <a {{if eq .status "2"}}class="on"{{end}} href="{{.statusurl}}status=2"><li>新品</li></a>
          <a {{if eq .status "3"}}class="on"{{end}} href="{{.statusurl}}status=3"><li>价格从低到高</li></a>
          <a {{if eq .status "4"}}class="on"{{end}} href="{{.statusurl}}status=4"><li>价格从高到低</li></a>
        </ul>
        <div>
          <form>
              价格
              <input type="number" name="min" value="{{.min}}" placeholder="&yen;"> - <input type="number" name="max" value="{{.max}}" placeholder="&yen;">
              <input type="hidden" name="bid" value="{{.bid}}">
              <input type="hidden" name="cid" value="{{.cid}}">
              <input type="hidden" name="search" value="{{.search}}">
              <button>确定</button>
            </form>
          </div>
        {{if .paginator}}
        <ul>
          {{if ne .paginator.currpage 1}}
          <a href="{{$.url}}page={{.paginator.prevpage}}"><li class="iconfont no">&#xe7ba;</li></a>
          {{else}}
          <li class="iconfont no">&#xe7ba;</li>
          {{end}}
          <li><span>{{.paginator.currpage}}</span>/{{.paginator.totalpages}}</li>
          {{if ne .paginator.currpage .paginator.totalpages}}
          <a href="{{$.url}}page={{.paginator.nextpage}}"><li class="iconfont">&#xe7bb;</li></a>
          {{else}}
          <li class="iconfont no">&#xe7bb;</li>
          {{end}}
        </ul>
        {{end}}
      </div>
    </div>
    <div class="searchCont">
      <div class="searchPrd">
        {{range .product}}
        <dl>
          <dt>
            <a href="/product/content?id={{.id}}"><img src="{{.pathname}}" alt=""></a>
          </dt>
          {{if .vprice}}
          <dd>&yen;<span>{{.vprice}}</span><s>&yen;{{.price}}</s></dd>
          {{else}}
          <dd>&yen;<span>{{.price}}</span></dd>
          {{end}}
          <span class="a-wrap"><a href="/product/content?id={{.id}}">{{.title}}</a></span>
          <dd><a href="/shop?id={{if .gname}}{{.gid}}{{else}}0{{end}}">{{if .gname}}{{.gname}}{{else}}{{$.system.name}}{{end}}</a></dd>
          <dd>
            <p>成交量<span>{{.sellnum}}</span></p>
            <p>评价<span>{{.enum}}</span></p>
          </dd>
          <i class="iconfont scadd" data-id="{{.id}}" data-minbuy="{{.minbuy}}">&#xe619;</i>
           {{if eq .active 1}}
          <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/gbuy.png" class="x">
          {{else if eq .active 2}}
          <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/sales.png" class="x">
          {{end}}
        </dl>
        {{end}}
      </div>
      {{if .paginator}}
        {{if ne .paginator.totalpages 1}}
        <div class="pageView">
          <b class="btn">
            {{if ne .paginator.currpage 1}}
            <a href="{{$.url}}page={{.paginator.prevpage}}"><b>&lt;&lt;上一页</b></a>
            {{else}}
            <b>&lt;&lt;上一页</b>
            {{end}}
            {{range $index,$page := .paginator.pages}}
            {{if eq $.paginator.currpage $page}} 
            <b>{{$page}}</b>
            {{else}}
            <a href="{{$.url}}page={{$page}}"><b>{{$page}}</b></a>
            {{end}}
            {{end}}
            <!-- <b class="more">...</b> -->
            {{if eq .paginator.currpage .paginator.totalpages}}
            <b>下一页&gt;&gt;</b>
            {{else}}
            <a href="{{$.url}}page={{.paginator.nextpage}}"><b>下一页&gt;&gt;</b></a>
            {{end}}
          </b>
          <b class="other">
            共{{.paginator.totalpages}}页，到第<input type="text" name="p">页<button id="go">确定</button>
          </b>
        </div>
        {{else}}
        <div class="pageView">
          <b class="btn">
          <a>1</a>
        </b>
        </div>
        {{end}}
      {{else}}
         <div class="pageView">
          <b class="btn">
          {{if lt $.pagep 1}}
          {{else}}
          <a href="{{$.url}}page={{$.pagep}}"><li class="iconfont no">上一页</li></a>
          {{end}}
          {{if .product}}
          <a href="{{$.url}}page={{$.pagel}}"><li class="iconfont no">下一页</li></a>
          {{end}}
      </b>
        </div>
      {{end}}
      <div class="searchRcmd searchPrd">
        {{range .recommend}}
        <dl>
          <dt>
            <a href="/product/content?id={{.id}}"><img src="{{.pathname}}" alt=""></a>
          </dt>
          {{if .vprice}}
          <dd>&yen;<span>{{.vprice}}</span><s>&yen;{{.price}}</s></dd>
          {{else}}
          <dd>&yen;<span>{{.price}}</span></dd>
          {{end}}
          <span class="a-wrap"><a href="/product/content?id={{.id}}">{{.title}}</a></span>
          <dd><a href="/shop?id={{if .gname}}{{.gid}}{{else}}0{{end}}">{{if .gname}}{{.gname}}{{else}}{{$.system.name}}{{end}}</a></dd>
          <dd>
            <p>成交量<span>{{.sellnum}}</span></p>
            <p>评价<span>{{.enum}}</span></p>
          </dd>
          <i class="iconfont scadd" data-id="{{.id}}" data-minbuy="{{.minbuy}}">&#xe619;</i>
          {{if eq .active 1}}
          <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/gbuy.png" class="x">
          {{else if eq .active 2}}
          <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/sales.png" class="x">
          {{end}}
        </dl>
        {{end}}
      </div>
    </div>
  {{template "pc/public/foot.html" .}}
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/js/jquery.min.js"></script>
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/xcConfirm.js"></script>
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/js/toast.js"></script>
</body>
  <script type="text/javascript">
     $('#go').click(function(){
    var totalpages={{.paginator.totalpages}};
    var num=$('input[name="p"]').val()
    if(num<=totalpages){
      window.location.href={{.url}}+`page=`+num
    }
  })
    $('.scadd').click(function(){
      var pid=$(this).attr('data-id')
      var minbuy=$(this).attr('data-minbuy')
      $.ajax({
        url:'/isShopcar',
        type:"get",
        data:{pid:pid},
        success:function(res){
          if (minbuy>1 && !res.isshopcar) {
            wxc.xcConfirm("该产品的最小购买数为"+minbuy,"confirm",{onOk:function(){
              $.ajax({
                url:'/shopcar',
                type:'post',
                data:{num:1,pid:pid,minbuy:minbuy},
                success:function(res){
                  if(res==0){
                    showToast('网络繁忙,请重试');
                  }else if(res==1){
                    showToast('加入购物车成功');
                  }else if(res==2||res==962){
                    wxc.xcConfirm("您还没有登入,请先登入","confirm",{onOk:function(){
                      window.location.href="/login"
                    }})
                  }else if(res==3){
                    showToast('库存不足');
                  }
                }
              })
            }})
          } else {
            $.ajax({
              url:'/shopcar',
              type:'post',
              data:{num:1,pid:pid,minbuy:minbuy},
              success:function(res){
                if(res==0){
                  showToast('网络繁忙,请重试');
                }else if(res==1){
                  showToast('加入购物车成功');
                }else if(res==2||res==962){
                  wxc.xcConfirm("您还没有登入,请先登入","confirm",{onOk:function(){
                    window.location.href="/login"
                  }})
                }else if(res==3){
                  showToast('库存不足');
                }
              }
            })
          }
        }
      })
      return false
   })
    $('.delAttr').click(function(){
      var id=$(this).attr('data-id')
      console.log(id)
      var url=window.location.href;
      console.log(url)
      url=url.split('&')
      for(var i=0;i<url.length;i++){
        var urlp=url[i].split('=')
        if(urlp[0]=="a"+id){
          url.splice(i,1)
        }
      }
      url=url.join('&')
      window.location.href=url
      })
  </script>
</html>